<style lang="less">
  .mylist:odd {
    color: red;
  }
  .mylist:even {
    color: green;
  }
</style>
<template>
  <view class="list">
  <view>
    <button @tap="add" size="mini">添加列表</button>
  </view>
    <view v-for="item in list" :key="id">
      <view @tap="tap" class="mylist">
        <text>{{item.id}}</text>: {{item.title}}
      </view>
    </view>
  </view>
</template>
<script>

  export default {
    data: {
      list: [
        {
          id: '0',
          title: 'loading'
        }
      ]
    }

    events: {
      'index-broadcast': (...args) => {
        let $event = args[args.length - 1]
        console.log(`${this.$name} receive ${$event.name} from ${$event.source.name}`)
      }
    }

    methods: {
      tap () {
        // this.num = this.num + 1
        console.log(this.$name + ' tap')
      },
      add () {
        let len = this.list.length
        this.list.push({id: len + 1, title: 'title_' + len})
      }
    }

    onLoad () {
    }
  }
</script>
